package com.xxx.common.dto;

import java.util.List;

import com.xxx.common.Const;

import lombok.Getter;

/**
 * @ClassName: Page 
 * @Description: 分页工具类
 * @author kang
 * @date 2017-01-07
 */
@Getter
public class Page<T>{
	
	private int currentPage = 1;        	 //当前页
	
	private int totalPage;  				 //总页数
	
	private int pageSize = Const.PAGE_SIZE;  //每页显示个数
	
	private int totalRecord; 				 //总记录数
	
	private List<T> list;					 //分页数据

	public Page(int currentPage, int totalRecord) {
		super();
		this.currentPage = currentPage;
		this.totalRecord = totalRecord;
		if(totalRecord % this.pageSize == 0){
			this.totalPage = totalRecord / this.pageSize;
		}else{
			this.totalPage = totalRecord / this.pageSize + 1;
		}
	}
	
	public Page(int currentPage, int totalRecord, List<T> list) {
		super();
		this.currentPage = currentPage;
		this.totalRecord = totalRecord;
		this.list = list;
		if(totalRecord % this.pageSize == 0){
			this.totalPage = totalRecord / this.pageSize;
		}else{
			this.totalPage = totalRecord / this.pageSize + 1;
		}
	}

	public Page(int currentPage, int pageSize, int totalRecord) {
		super();
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.totalRecord = totalRecord;
		if(totalRecord % pageSize == 0){
			this.totalPage = totalRecord / pageSize;
		}else{
			this.totalPage = totalRecord / pageSize + 1;
		}
	}
	
	public Page(int currentPage, int pageSize, int totalRecord, List<T> list) {
		super();
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.totalRecord = totalRecord;
		this.list = list;
		if(totalRecord % pageSize == 0){
			this.totalPage = totalRecord / pageSize;
		}else{
			this.totalPage = totalRecord / pageSize + 1;
		}
	}
	
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public void setTotalRecord(int totalRecord) {
		this.totalRecord = totalRecord;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	@Override
	public String toString() {
		return "Page [currentPage=" + currentPage + ", totalPage=" + totalPage + ", pageSize=" + pageSize
				+ ", totalRecord=" + totalRecord + "]";
	}
}
